#include <boost/test/unit_test.hpp>

#include "date.h"

using namespace std;
using namespace aviation;

BOOST_AUTO_TEST_CASE(TestDateDefaultConstructor)
{
	//Constructs an object with an appropriate string
	Date date1;

	BOOST_REQUIRE(date1.AsString() == "01012000");
}

BOOST_AUTO_TEST_CASE(TestDateConstructor)
{
	// A date with good input
	aviation::Date date1(std::string("01012012"));
	// Check correct output
	BOOST_REQUIRE(date1.AsString() == "01012012");

	//Test the following bad inputs.
	BOOST_CHECK_THROW(aviation::Date(std::string("1012012")), std::exception);
	BOOST_CHECK_THROW(aviation::Date(std::string("010120120")), std::exception);
	BOOST_CHECK_THROW(aviation::Date(std::string("")), std::exception);
	// Test invalid day date 40/01/2012
	BOOST_CHECK_THROW(aviation::Date(std::string("40012012")), std::exception);
	// Test invalid day date 33/01/2012
	BOOST_CHECK_THROW(aviation::Date(std::string("33012012")), std::exception);
	// Test invalid month 01/20/2012
	BOOST_CHECK_THROW(aviation::Date(std::string("01202012")), std::exception);
	// Test invalid month 01/14/2012
	BOOST_CHECK_THROW(aviation::Date(std::string("01142012")), std::exception);
	//Test invalid year 01/01/3000
	BOOST_CHECK_THROW(aviation::Date(std::string("01013000")), std::exception);
	//Test invalid year 01/01/2100
	BOOST_CHECK_THROW(aviation::Date(std::string("01012100")), std::exception);
	//Test invalid date 30/02/2012
	BOOST_CHECK_THROW(aviation::Date(std::string("30022012")), std::exception);

}

BOOST_AUTO_TEST_CASE(TestDateCopyConstructor)
{
	// Copies the Date from another.
	Date date1("09102002");
	Date date2(date1);
	BOOST_REQUIRE(date1.AsString() == date2.AsString());

}

BOOST_AUTO_TEST_CASE(TestDateAssignmentOperator)
{
	// Assignment operator, copies from 'other'
	Date date1("12122007");
	Date date2;
	date2 = date1;
	BOOST_REQUIRE(date1.AsString() == date2.AsString());
}

BOOST_AUTO_TEST_CASE(TestDateComparisonEqualOperator)
{
	//Returns true if they are the same, or false if they arent
	Date date1(string("03072012"));
	Date date2(string("03072012"));

	BOOST_REQUIRE(date1 == date2);



}

BOOST_AUTO_TEST_CASE(TestDataComparisonNotEqualoperator)
{
	//Returns true if they are not the same, or false if they are
	Date date1(string("15082012"));
	Date date2(string("03072012"));

	BOOST_REQUIRE(date1 != date2);


}

BOOST_AUTO_TEST_CASE(TestDateComparisonLessthanoperator)
{
	//Returns true if it is less than other, or false if it is greater than
	Date date1(string("03072012"));
	Date date2(string("12032001"));
	
	BOOST_REQUIRE(date2 < date1);

}

BOOST_AUTO_TEST_CASE(TestGetDay)
{
	//return the day
    Date date1(string("26062009"));

	BOOST_REQUIRE(date1.GetDay() == 26);

}

BOOST_AUTO_TEST_CASE(TestGetMonth)
{
	//return the month
    Date date1(string("26062009"));

	BOOST_REQUIRE(date1.GetMonth() == 06);

}

BOOST_AUTO_TEST_CASE(TestGetYear)
{
	//return the year
    Date date1(string("26062009"));

	BOOST_REQUIRE(date1.GetYear() == 2009);

}

BOOST_AUTO_TEST_CASE(TestDateAsString)
{
	//return the data AsString as a string
    Date date1(string("26062009"));

	BOOST_REQUIRE(date1.AsString() == "26062009");

}